<template>
	<view class="page-content">
		<view class="flex-between" style="background: #fff;padding: 15px;align-items: center;">
			<view class="flex-start">
				<image src="../../../static/wallet/redract.png" mode=""
					style="width: 4px;height: 21px;margin-right: 5px;">
				</image>
				<text>已生成的优惠券</text>
			</view>

			<view class="red-btn" @click="toAddCoupon">
				生成的优惠券
			</view>


		</view>

		<view class="coupon-list">
			<view class="coupon-item flex-between" v-for="item in coupon_list" :key="item.id">
				<view class="flex-column-center" style="width: 159px;background: #f00;color: #fff;min-height: 100%;margin-right: 10px;border-radius: 10px 0px 0px 10px;">
					<view class="flex-start" style="align-items: flex-end;margin-bottom: 15px;margin-top: 15px;">
						<text style="font-size: 20px;font-weight: 500;">￥</text>
						<text style="font-size: 35px;font-weight: 700;transform: translateY(5px);">{{item.coupon_price}}</text>
					</view>

					<view class="red-word">
						{{item.coupon_type}}
					</view>

					<view class="white-word" style="margin: 10px 15px;">
						{{item.use_price}}
					</view>
				</view>

				<view class="flex-column-between" style="align-items: flex-start;margin: 5px;flex:1">
					<view style="font-size: 18px;margin-bottom: 20px;">{{item.coupon_name}}</view>
					<text style="margin-bottom: 5px;">数量：{{item.use_number}}</text>
					<text style="margin-bottom: 5px;">到期时间：{{item.off_date}}</text>
					<text>适用钓场：{{item.place_count}}个</text>
				</view>

				<view class="flex-column-center" @click="toDetail(item)">
					<uni-icons type="right" size="30" style="color: #f00;"></uni-icons>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		get_show_coupon
	} from '../../../utils/couponApi/index.js'
	export default {
		data() {
			return {
				title: 'Hello',
				coupon_list: []
			}
		},
		onLoad() {
			this.get_coupon()
		},
		methods: {
			toAddCoupon() {
				uni.navigateTo({
					url: `/pages/fashingSite/couponManagement/addCoupon`
				})
			},
			async get_coupon() {
				let res = await get_show_coupon({})
				console.log(res);
				this.coupon_list = res.coupon_data
			},
			toDetail(item){
				item.id=1
				uni.navigateTo({
					url: `/pages/fashingSite/couponManagement/couponDetail?id=${item.id}`
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.page-content {
		height: calc(100vh - 44px);
		background: #F3F4F6;
	}

	.red-btn {
		background: #D43030;
		color: #fff;
		font-size: 14px;
		padding: 7px 20px;
		border-radius: 16.5px;
	}
	.coupon-item{
		align-items: center;
		background: #fff;
		border-radius: 10px;
		margin: 15px;
		height: 100%;
		font-size: 14px
	}
	.red-word{
		background: #fff;
		color: #D43030;
		padding:2px 5px;
	}
</style>